class DKTab_MidGameAchievements extends KFTab_MidGamePerks;

var localized string NextInfoStr;

function ShowPanel(bool bShow)
{
	super(MidGamePanel).ShowPanel(bShow);

	if ( bShow )
	{
		if ( Class'ClientPerkRepLink'.Static.FindStats(PlayerOwner()) != none )
		{
			// Initialize the List
			lb_PerkSelect.List.InitList(None);
			lb_PerkProgress.List.InitList();
		}
		InitGRI();
	}
}

function OnPerkSelected(GUIComponent Sender)
{
	local ClientPerkRepLink ST;
	local byte Idx;

	ST = Class'ClientPerkRepLink'.Static.FindStats(PlayerOwner());
	if ( ST == None || ST.CacheAchievements.Length == 0 )
	{
		if( ST!=None )
			ST.ServerRequestAchievements();

		lb_PerkEffects.SetContent("Please wait while your client is loading the achievements...");
	}
	else
	{
		Idx = lb_PerkSelect.GetIndex();
		lb_PerkEffects.SetContent(ST.CacheAchievements[Idx].AchievementClass.Static.GetAchievementInfoText(ST.CacheAchievements[Idx].CurrentLevel,1));
		lb_PerkProgress.List.PerkChanged(KFStatsAndAchievements, Idx);
	}
}

function bool OnSaveButtonClicked(GUIComponent Sender)
{
	local ClientPerkRepLink ST;

	ST = Class'ClientPerkRepLink'.Static.FindStats(PlayerOwner());
	if ( ST != None && lb_PerkSelect.GetIndex() >= 0 )
		ST.ServerSelectAchievement(ST.CacheAchievements[lb_PerkSelect.GetIndex()].AchievementClass);
	return true;
}

defaultproperties
{
	Begin Object Class=GUIScrollTextBox Name=PerkEffectsScroll
		WinWidth=0.465143
		WinHeight=0.313477
		WinLeft=0.500554
		WinTop=0.083121
		CharDelay=0.0025
		EOLDelay=0.1
		TabOrder=9
		StyleName="NoBackground"
	End Object
	lb_PerkEffects=PerkEffectsScroll

	Begin Object class=DKAchievementSelectListBox Name=AchievementSelectList
		WinWidth=0.437166
		WinHeight=0.742836
		WinLeft=0.029240
		WinTop=0.057760
	End Object
	lb_PerkSelect=AchievementSelectList

	Begin Object class=DKAchievementProgressListBox Name=AchievementProgressList
		WinWidth=0.463858
		WinHeight=0.341256
		WinLeft=0.499269
		WinTop=0.476850
	End Object
	lb_PerkProgress=AchievementProgressList

	NextInfoStr="||Next level effects:|"
}
